package com.allwees.bs.module.pms.vo;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import com.allwees.bs.module.pms.entity.Category;
import com.allwees.bs.module.pms.entity.Product;
import com.allwees.bs.module.pms.entity.Sku;
import lombok.*;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author linqiu
 * @create 2019/11/1 11:38
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ExportSkuVo extends BaseRowModel {
    @ExcelProperty(value = "*库存sku编号", index = 0)
    private String no;

    @ExcelProperty(value = "*库存sku名称", index = 1)
    private String name; //目前系统没有，拿skuNO代替

    @ExcelProperty(value = "库存sku英文名称", index = 4)
    private String nameEn;

    @ExcelProperty(value = "sku状态(自动创建、等待开发、正常销售", index = 2)
    private String status;

    @ExcelProperty(value = "主SKU", index = 3)
    private String productNo;

    @ExcelProperty(value = "成本价(采购价)", index = 5)
    private String costPrice;

    @ExcelProperty(value = "售价", index = 6)
    private String retailPrice;

    @ExcelProperty(value = "品牌", index = 7)
    private String brand;

    @ExcelProperty(value = "商品目录", index = 8)
    private String category;

    @ExcelProperty(value = "申报品名(中文)", index = 9)
    private String declareNameCn;

    @ExcelProperty(value = "申报品名(英文)", index = 10)
    private String declareNameEn;

    @ExcelProperty(value = "商品自定义分类(多个用英文';'号隔开)", index = 11)
    private String customCategory;

    @ExcelProperty(value = "商品仓库", index = 12)
    private String warehouse;

    @ExcelProperty(value = "仓位", index = 13)
    private String warehousePosition;

    @ExcelProperty(value = "仓库成本价", index = 14)
    private String warehouseCostPrice;

    @ExcelProperty(value = "库存", index = 15)
    private String quantity;

    @ExcelProperty(value = "商品重量", index = 16)
    private String weight;

    @ExcelProperty(value = "供应商", index = 17)
    private String supplierName;

    @ExcelProperty(value = "上次采购价格", index = 18)
    private String lastBuyAmt;

    @ExcelProperty(value = "最低采购价格", index = 19)
    private String minBuyAmt;

    @ExcelProperty(value = "供应商商品网址", index = 20)
    private String supplierProductUrl;

    @ExcelProperty(value = "销售员", index = 21)
    private String salesor;

    @ExcelProperty(value = "美工", index = 22)
    private String artDesigner;

    @ExcelProperty(value = "采购员", index = 23)
    private String buyer;

    @ExcelProperty(value = "采购天数", index = 24)
    private String buyDays;

    @ExcelProperty(value = "最小采购数量", index = 25)
    private String mixBuyQuantity;

    @ExcelProperty(value = "最大采购数量", index = 26)
    private String maxBuyQuantity;

    @ExcelProperty(value = "库存警戒天数", index = 27)
    private String stockWarnDays;

    @ExcelProperty(value = "警戒库存", index = 28)
    private String warnStockQuantity;

    @ExcelProperty(value = "配货员", index = 29)
    private String distributor;

    @ExcelProperty(value = "质检标准", index = 30)
    private String qualityReviewStandard;

    @ExcelProperty(value = "包材", index = 31)
    private String packingMaterials;

    @ExcelProperty(value = "可包装个数", index = 32)
    private String packages;

    @ExcelProperty(value = "原厂SKU", index = 33)
    private String originalSku;

    @ExcelProperty(value = "是否带电池（0/1）", index = 34)
    private String isWithBattery;

    @ExcelProperty(value = "库存图片地址", index = 35)
    private String imgUrl;

    @ExcelProperty(value = "商品备注", index = 36)
    private String remark;

    @ExcelProperty(value = "销售备注", index = 37)
    private String saleRemark;

    @ExcelProperty(value = "采购备注", index = 38)
    private String buyRemark;

    @ExcelProperty(value = "虚拟sku(多个用英文';'分割)", index = 39)
    private String virtualSkus;

    @ExcelProperty(value = "商品尺寸长(cm)", index = 40)
    private String length;

    @ExcelProperty(value = "商品尺寸宽(cm)", index = 41)
    private String width;

    @ExcelProperty(value = "商品尺寸高(cm)", index = 42)
    private String height;

    @ExcelProperty(value = "开发员", index = 43)
    private String developer;

    @ExcelProperty(value = "申报价格($)", index = 44)
    private String declarePrice;

    @ExcelProperty(value = "液体化妆品（非液体、液体(化妆品)、非液体(化妆品)、液体(非化妆品)）", index = 45)
    private String liquid;

    @ExcelProperty(value = "是否粉末（0/1）", index = 46)
    private String isPowder;

    @ExcelProperty(value = "是否带磁（0/1）", index = 47)
    private String isMagnetism;

    @ExcelProperty(value = "采购方式（分仓采购/联合采购）", index = 48)
    private String buyType;

    @ExcelProperty(value = "报关编码", index = 49)
    private String declareCode;

    @ExcelProperty(value = "创建时间(2018/12/18 23:59:59)", index = 50)
    private String createAt;

    public ExportSkuVo(Category category, Product product, Sku sku) {
        no = sku.getCustomNo();
        name = product.getName();
        status = "自动创建";//默认自动创建
//        productNo = product.getCustomNo();
        nameEn = product.getName();
        costPrice = sku.getRetailPrice().toPlainString();
        retailPrice = sku.getRetailPrice().toPlainString();

        quantity = "0";
        weight = sku.getWeight() == null ? "" : sku.getWeight().toString();

//        createAt = DateUtil.formatDate(sku.getCreatedAt(), "yyyy/MM/dd HH:mm:ss");

        imgUrl = StringUtils.isBlank(sku.getPhotosStr()) ? product.getMainPhoto() : sku.getPhotosStr().split(",")[0];

        this.category = category == null ? "" : category.getNameZh();
    }
}
